/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelBuscarGrupo.java
 *
 * Created on 19/10/2014, 07:23:37 PM
 */
package mx.com.ugto.caadi.asistencias.gui;

import java.util.List;
import mx.com.ugto.caadi.asistencias.bean.Grupo;
import mx.com.ugto.caadi.asistencias.dao.GrupoDAO;
import mx.com.ugto.caadi.asistencias.gui.model.ModeloTablaGrupos;

/**
 *
 * @author Rolando
 */
public class PanelBuscarGrupo extends javax.swing.JPanel {

    private ModeloTablaGrupos modeloTabla;
    
    /** Creates new form PanelBuscarGrupo */
    public PanelBuscarGrupo() {
        initComponents();
        modeloTabla = new ModeloTablaGrupos();
        tblGrupos.setModel(modeloTabla);
    }
    
    void cargarDatosTabla() {
        modeloTabla = new ModeloTablaGrupos();
        List<Grupo> lstAlumnos;
        GrupoDAO dao = new GrupoDAO();
        lstAlumnos = dao.findAll();
        for (Grupo grupo : lstAlumnos) {
            modeloTabla.agregarAlumno(grupo);
        }
        tblGrupos.setModel(modeloTabla);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlBotones = new javax.swing.JPanel();
        btnNuevo = new javax.swing.JButton();
        btnEditar = new javax.swing.JButton();
        scrGrupos = new javax.swing.JScrollPane();
        tblGrupos = new javax.swing.JTable();

        setLayout(new java.awt.BorderLayout());

        pnlBotones.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        btnNuevo.setText("Nuevo");
        pnlBotones.add(btnNuevo);

        btnEditar.setText("Editar");
        pnlBotones.add(btnEditar);

        add(pnlBotones, java.awt.BorderLayout.PAGE_START);

        tblGrupos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        scrGrupos.setViewportView(tblGrupos);

        add(scrGrupos, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnEditar;
    private javax.swing.JButton btnNuevo;
    private javax.swing.JPanel pnlBotones;
    private javax.swing.JScrollPane scrGrupos;
    private javax.swing.JTable tblGrupos;
    // End of variables declaration//GEN-END:variables
}
